<!DOCTYPE HTML>
<html>
<head>
  <title>DB topology</title>
  <style>
    .keyspace {
      font-family: monospace;
    }
    td {
      border: 1px solid black;
      vertical-align:text-top;
    }
    ul.tablet-list li {
      list-style-type: none;
      margin: 0px;
      position: relative;
    }
    ul.tablet-list {
    padding-left: 0px;
    }
    table.keyspace {
      border-collapse: collapse;
    }
    table.keyspace td {
      padding-left: 1em;
      padding-right: 1em;
    }
    table.keyspace td.legend {
      text-align: center;
      padding-left: 1ex;
      padding-right: 1ex;
    }
    table.keyspace thead {
      text-align: center;
      border-color: #666;
      background-color: #dedede;
    }
    .not-replicating {
      text-decoration: line-through;
    }

  </style>
</head>
<body>
  {{with .Error}}
    <h1>{{.}}</h1>
  {{end}}
  {{with .Topology}}
    <h1>Assigned</h1>
    {{range $keyspace, $shards := .Assigned}}
      <h2><a href="/zk/global/vt/keyspaces/{{$keyspace}}">{{$keyspace}}</a></h2>
      <table class="keyspace">
	<thead>
	  {{ range $i, $shard := $shards.ShardNodes }}
	  {{if intequal $i 0}}<td class="legend">type</td>{{end}}
	  <td><a href="/zk/global/vt/keyspaces/{{$keyspace}}/shards/{{$shard.Name}}">{{$shard.Name}}</a></td>
	  {{end}}
	</thead>
	<tbody>
	  {{range $processedType := $shards.TabletTypes}}

	  <tr>
	    {{range $i, $shard := $shards.ShardNodes}}
	    {{if intequal $i 0}}<td class="legend">{{$processedType}}</td>{{end}}
	    <td>
	      <ul class="tablet-list">
		{{range index $shard.TabletNodes $processedType}}
		{{template "tablet.html" .}}
		{{end}}
	      </ul>
	    </td>
	    {{end}}
	  </tr>
	  {{end}}
	</tbody>
      </table>
    {{end}}
    <h1>Idle</h1>
    <ul>
      {{range .Idle}}
        {{template "tablet.html" .}}
      {{end}}
    </ul>
    <h1>Scrap</h1>
    <ul>
    {{range .Scrap}}
      {{template "tablet.html" .}}
    {{end}}
    </ul>
  {{end}}

</body>
</html>
